<template>
	<view class="container">
		<navigator class="list-cell b-b m-t" url="grzl/grzl" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{$t('Profile')}}</text>
			<image mode="aspectFit" style="width: 30upx; height: 30upx;" :src="staticUrl + 'fh2.png'"></image>
		</navigator>
		<block v-for="(item,index) in artlist" :key="index">
		<navigator class="list-cell b-b" :url="'about?id='+item.id" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{item.title}}</text>
			<image mode="aspectFit" style="width: 30upx; height: 30upx;" :src="staticUrl + 'fh2.png'"></image>
		</navigator>
		</block>
		<view class="list-cell">
			<text class="cell-tit">{{$t('Version')}}</text>
			<text class="cell-tip">{{version}}</text>
		</view>
		<view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">{{$t('Sign out')}}</text>
		</view>
	</view>
</template>

<script>
	import {  
	    mapMutations  
	} from 'vuex';
	export default {
		data() {
			return {
				artlist:[],
				version:'1.0',
				staticUrl:this.$config.staticUrl,
			}
		},
		onShow() {
			uni.setNavigationBarTitle({
			    title: this.$t('Settings')
			});
		},
		onLoad() {
			// #ifdef APP-PLUS
			this.version=plus.runtime.version
			// #endif
			this.article()
		},
		methods:{
			...mapMutations(['logout']),
			
			async article(){
				let data = {type:0};
				let [err,res] =await this.$httpas.get('/api/index/artlist',data);
				if(res.data.code == 1){
					this.artlist = res.data.data
				}
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: this.$t('Login out confirm'),
				    success: (e)=>{
				    	if(e.confirm){
				    		uni.clearStorage("userinfo");
				    		setTimeout(()=>{
				    			uni.navigateBack();
				    		}, 200)
				    	}
				    }
				});
			},
			clearCache(){
				uni.clearStorage();
				uni.showToast({
					title:this.$t('Operation completed'),
					success: ()=>{
						uni.navigateTo({
							url:'/pages/login/login'
						})
					}
				})
			}
		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
</style>
